const fs = require('fs')
const axios = require('axios')
const path = require('path')
const request = require('request')
const md5 = require('md5-file')

//const targetBaseUrl = 'http://www.jnaw.top/cwbuFile/picc-json'
const targetBaseUrl = 'http://192.168.55.100/cwbu/zyh'
const zyhFileUrl = '/step_list.json'
const localFile = './step_list.json'

const dirPath = path.join(__dirname, "ab")

let combine = async _ => {
    let zyhList = {}
    let stepList = {}

    await axios.get(targetBaseUrl + zyhFileUrl).then(res => zyhList = res.data)

    // 打印json
    let list = JSON.stringify(zyhList, null, 4)
    console.log(list)

    // 写入
    fs.writeFile(localFile, list, function (err) {
        if (err) {
            throw err;
        }
        console.log('写入成功' + localFile);
        // 读取
        // fs.readFile(localFile, 'utf-8', function (err, data) {
        //     if (err) {
        //         throw err;
        //     }
        //     console.log('读取成功');
        //     //console.log(data);
        // });
    });


}

combine()
